function count_same_elements(collection) {
  let obj={};
  let arr=[];
  for(let item of collection){
   if(! obj[item]){
        obj[item]={};
        obj[item].key=item;
        obj[item].count=1;
       }else{
         obj[item].count++
    }
  }
  for( let key in obj){
      arr.push(obj[key]);
  }
  console.log(arr);
  return arr; //在这里写入代码
}

module.exports = count_same_elements;
